﻿/**
客户业务
**/
//工序派工方法
function gxPaiGong(plCode, gxCode) {   
    $.ajax({
        url: "../Plan/JAssignment",
        data: { plCode: plCode, gxCode: gxCode },
        dataType: "json",
        type: "POST",
        success: function (rsl) {
            if (rsl.Result) {
                layer.alert("工序派工完成", { icon: 6 }, function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                });
            } else {
                layer.msg(rsl.Message);
            }
        }
    });
}
var inStart = "0";
//工序数据保存
function saveData() {
    if (view == "1") {
        layer.msg("对不起，您无权修改");
        return;
    }
    var json = FormToJson("AddForm");
 
    $.ajax({
        url: "../Plan/SavePlanGongXu",
        data: { gxStr: JSON.stringify(FormToJson("AddForm")), dataId: dataId },
        dataType: "json",
        type: "POST",
        success: function (data) {
            if (data.Result) {
                var id = $("input[ name='id']").val();
                var msg = "信息修改成功";
                if (id == "0" || id == "") {
                    msg = "信息添加成功";
                }
                layer.alert(msg, { icon: 6 }, function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                });
            } else {
                layer.msg(data.Message);
            }
        }
    });
}

/**
卷材制袋计划层信息
**/
function getJuanPlan(plCode,ceng) {
    $.ajax({
        url: "../Plan/getJuanPlanByCode?plCode=" + plCode + "&ceng=" + ceng,
        dataType: "json",
        type: "POST",
        success: function (data) {
            if (data.Result) {
                $.each(data.Data, function (name, value) {
                    $("input[ name='" + name + "']").val(value);
                });
            }

        }
    });
}
/**
   获取计划信息并进行显示
   **/
function setPlanInfo() {
    $.ajax({
        url: "../Plan/getPlanInfoByCode",
        type: "post",
        data: { plCode: plCode },
        async: false,
        success: function (data) {
            if (data.Result) {
                var json = data.Data[0];
                $("input[ name='cemian']").val(json.cu_cemian);
                $("input[ name='zhengmian']").val(json.cu_zhengmian);
                $("input[ name='changdu']").val(json.cu_changdu);
                $("#cemian").attr("readOnly", true);
                $("#zhengmian").attr("readOnly", true);
                $("#changdu").attr("readOnly", true);
            }
        }
    });
}

/**
 生产工序

 **/
function loadProductGx(kjId) {
    $.ajax({
        url: "../Basis/GetCommonData",
        data: { type: "proGx" },
        dataType: "json",
        type: "POST",
        async: false,
        success: function (data) {
            if (data.Result) {
                var datas = data.Data;
                for (var i = 0 ; i < datas.length; i++) {
                    if (datas[i].specFile != "0") {
                        $("#" + kjId).append("<option value=\"" + datas[i].cCode + "\" >" + datas[i].cName + "(" + datas[i].cCode + ")" + "</option>");
                    }

                }
            }

        }
    });
}